package com.labichaoka.chaoka.ui.home.fragment.my.set;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.labichaoka.chaoka.R;
import com.labichaoka.chaoka.base.BaseActivity;
import com.labichaoka.chaoka.base.MyApplication;
import com.labichaoka.chaoka.ui.MainActivity;
import com.labichaoka.chaoka.ui.home.fragment.my.set.about.AboutUsActivity;
import com.labichaoka.chaoka.ui.home.fragment.my.set.info.PersonInfoDisplayActivity;
import com.labichaoka.chaoka.utils.ToastUtils;

import butterknife.BindView;
import butterknife.OnClick;

public class SettingActivity extends BaseActivity implements SettingView {
    @BindView(R.id.next1)
    TextView next1;
    @BindView(R.id.next2)
    TextView next2;
    @BindView(R.id.verify)
    TextView verify;

    private SettingPresenter presenter;
    private String idcard;

    @Override
    protected int initLayoutId() {
        return R.layout.activity_setting;
    }

    @Override
    protected void initView() {
        next1.setTypeface(iconfont);
        next2.setTypeface(iconfont);
    }

    @Override
    protected void initData() {
        presenter=new SettingPresenterImpl(this,new SettingInteractorImpl());
        idcard=getIntent().getStringExtra("idcard");
        if (!TextUtils.isEmpty(idcard)&&idcard.equals("1")){
            verify.setText("已认证");
            verify.setTextColor(getResources().getColor(R.color.font_ff4340));
        }else{
            verify.setText("未认证");
            verify.setTextColor(getResources().getColor(R.color.font_3a3a38));
        }

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @OnClick({R.id.about_layout, R.id.info_layout,R.id.logout})
    public void click(View v) {
        switch (v.getId()) {
            case R.id.about_layout:
                gotoActivity(mContext, AboutUsActivity.class, null);
                break;
            case R.id.info_layout:
                gotoActivity(mContext, PersonInfoDisplayActivity.class, null);
                break;
            case R.id.logout:
                presenter.loginOut();
                break;
        }
    }

    @Override
    public void showProgress() {
        showLoadingProgress();
    }

    @Override
    public void hideProgress() {
        hideLoadingProgress();
    }

    @Override
    public void showMessage(String str) {
        ToastUtils.show(str);
    }

    @Override
    public void toLogin() {

        MyApplication.finishAllActivityExceptMain(MainActivity.class);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        presenter.onDestroy();
    }
}
